package org.nepu.scr.indexrate.converter.drillingrate.emergencycapability;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.emergencycapability.DataInput;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class DataInputConverter implements AttributeConverter<DataInput, String> {
    @Override
    public String convertToDatabaseColumn(DataInput dataInput) {
        return JSONUtil.toJsonStr(dataInput);
    }

    @Override
    public DataInput convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, DataInput.class);
    }
}
